package com.tianqu.tms.entity;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.core.util.DateUtil;
import com.tianqu.tms.dao.MarketCarInfoTempDao;
import com.tianqu.tms.dao.TmsDao;
import com.tianqu.tms.dao.ViewListDao;
import com.tianqu.tms.dto.MarketCarInfoTempDto;

public class MarketCarInfoTemp extends ViewListManager {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long id;
	private String vin;
	private String vinPhoto;
	private String photo1;
	private String photo2;
	private String photo3;
	private String photo4;
	private String photo5;
	private String photo6;
	private String photo7;
	private String photo8;
	private int attestStatus;
	private int checkStatus;
	private String checkImgPath;
	private Timestamp insertTime;
	private String insertTimeS;
	private String insertUser;
	private int isMatch;
	private int cssFlag;
	private String carPhoto;
	private int num;
	private String serial;
	private String checkPhoto1;
	private String checkPhoto2;
	private String checkPhoto3;
	private String checkPhoto4;
	private String checkPhoto5;
	private String checkPhoto6;
	private String checkPhoto7;
	private String checkPhoto8;
	private String checkPhoto9;
	private String checkPhoto10;
	private String checkPhoto11;
	private String checkPhoto12;
	private String checkPhoto13;
	private String checkPhoto14;
	private String checkPhoto15;
	private int mileage;
	private int color;
	private int tag1Skip;
	private int tag2Skip;
	private int tag3Skip;
	private String tempLicensePlate;
	
	public static MarketCarInfoTemp getInstance() {
		MarketCarInfoTemp marketCarInfo = new MarketCarInfoTemp();
		marketCarInfo.setExisting(false);
		return marketCarInfo;
	}
		
    public List loadPadHistory()throws TmsDaoException{
    	List padList = new ArrayList();
    	MarketCarInfoTempDao carInfoDao = (MarketCarInfoTempDao) TmsDao.getInstance(TmsDao.TMSAPP_MARKET_CAR_INFO_TEMP,
				getPageNo(), getMaxIndex(), getSortKey(), isAsc());
		ViewListDao idao = (ViewListDao) TmsDao.getViewListDao((TmsDao) carInfoDao,
				TmsDao.TMSAPP_MARKET_CAR_INFO_TEMP);
    	List<MarketCarInfoTempDto> picList = new ArrayList<MarketCarInfoTempDto>();
    	picList = carInfoDao.loadPadHistory();
    	int i=0;
    	if(picList != null && picList.size() > 0){
    		for(MarketCarInfoTempDto dto : picList){
        		if(i%2 == 0){
        			dto.setCssFlag(1);
    			}else{
    				dto.setCssFlag(2);
    			}
        		dto.setInsertTimeS(DateUtil.getTimeByTimeStamp(dto.getInsertTime()));
        		dto.setNum(i+1);
        		padList.add(dto);
        		i++;
        	}
    	}  	
    	setPagingInfo(idao);
    	return padList;
    }
    public MarketCarInfoTemp findCarTempInfoById(long id)throws TmsDaoException{
    	MarketCarInfoTempDao mDao = (MarketCarInfoTempDao)TmsDao.getInstance(TmsDao.TMSAPP_MARKET_CAR_INFO_TEMP);
    	MarketCarInfoTempDto dto = mDao.findCarTempInfoById(id);
    	MarketCarInfoTemp marketCarInfo = new MarketCarInfoTemp();
    	if(dto != null){
    		marketCarInfo = setEntityFromDto(marketCarInfo,dto);
    	}    	
    	return marketCarInfo;
    }
    public void updateCarMatchInfo(MarketCarInfoTemp carInfoTemp)throws TmsDaoException{
    	MarketCarInfoTempDao mDao = (MarketCarInfoTempDao)TmsDao.getInstance(TmsDao.TMSAPP_MARKET_CAR_INFO_TEMP);
    	MarketCarInfoTempDto dto = new MarketCarInfoTempDto();
    	dto.setId(carInfoTemp.getId());
    	dto.setSerial(carInfoTemp.getSerial());
    	dto.setIsMatch(carInfoTemp.getIsMatch());
    	mDao.updateCarMatchInfo(dto);
    }
    public void updateCarDeleteInfo(long id,int isMatch)throws TmsDaoException{
    	MarketCarInfoTempDao mDao = (MarketCarInfoTempDao)TmsDao.getInstance(TmsDao.TMSAPP_MARKET_CAR_INFO_TEMP);
    	mDao.updateCarDeleteInfo(id,isMatch);
    }
    public MarketCarInfoTemp findCarTempInfoByVin(String vin)throws TmsDaoException{
    	MarketCarInfoTempDao mDao = (MarketCarInfoTempDao)TmsDao.getInstance(TmsDao.TMSAPP_MARKET_CAR_INFO_TEMP);
    	MarketCarInfoTempDto dto = mDao.findCarTempInfoByVin(vin);
    	MarketCarInfoTemp marketCarInfo = new MarketCarInfoTemp();
    	if(dto != null){
    		marketCarInfo = setEntityFromDto(marketCarInfo,dto);
    	}    	
    	return marketCarInfo;
    }
    /**
	 * 
	 * 将dto信息set到entity中
	 */
	private MarketCarInfoTemp setEntityFromDto(MarketCarInfoTemp entity, MarketCarInfoTempDto dto) {
		entity.setId(dto.getId());
		entity.setVin(dto.getVin());
		entity.setVinPhoto(dto.getVinPhoto());
		entity.setPhoto1(dto.getPhoto1());
		entity.setPhoto2(dto.getPhoto2());
		entity.setPhoto3(dto.getPhoto3());
		entity.setPhoto4(dto.getPhoto4());
		entity.setPhoto5(dto.getPhoto5());
		entity.setPhoto6(dto.getPhoto6());
		entity.setPhoto7(dto.getPhoto7());
		entity.setPhoto8(dto.getPhoto8());
		entity.setAttestStatus(dto.getAttestStatus());
		entity.setCheckStatus(dto.getCheckStatus());
		entity.setCheckImgPath(dto.getCheckImgPath());
		entity.setInsertTime(dto.getInsertTime());
		entity.setInsertUser(dto.getInsertUser());
		entity.setIsMatch(dto.getIsMatch());
		entity.setCheckPhoto1(dto.getCheckPhoto_1());
		entity.setCheckPhoto2(dto.getCheckPhoto_2());
		entity.setCheckPhoto3(dto.getCheckPhoto_3());
		entity.setCheckPhoto4(dto.getCheckPhoto_4());
		entity.setCheckPhoto5(dto.getCheckPhoto_5());
		entity.setCheckPhoto6(dto.getCheckPhoto_6());
		entity.setCheckPhoto7(dto.getCheckPhoto_7());
		entity.setCheckPhoto8(dto.getCheckPhoto_8());
		entity.setCheckPhoto9(dto.getCheckPhoto_9());
		entity.setCheckPhoto10(dto.getCheckPhoto_10());
		entity.setCheckPhoto11(dto.getCheckPhoto_11());
		entity.setCheckPhoto12(dto.getCheckPhoto_12());
		entity.setCheckPhoto13(dto.getCheckPhoto_13());
		entity.setCheckPhoto14(dto.getCheckPhoto_14());
		entity.setCheckPhoto15(dto.getCheckPhoto_15());
		entity.setTempLicensePlate(dto.getTempLicensePlate());
		entity.setSerial(dto.getSerial());
		entity.setMileage(dto.getMileage());
		entity.setColor(dto.getColor());
		entity.setTag1Skip(dto.getTag1Skip());
		entity.setTag2Skip(dto.getTag2Skip());
		entity.setTag3Skip(dto.getTag3Skip());
		return entity;
	}   
    

	/**
	 * @param id the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @return the id
	 */
	public long getId() {
		return id;
	}

	/**
	 * @param vin the vin to set
	 */
	public void setVin(String vin) {
		this.vin = vin;
	}

	/**
	 * @return the vin
	 */
	public String getVin() {
		return vin;
	}

	/**
	 * @param vinPhoto the vinPhoto to set
	 */
	public void setVinPhoto(String vinPhoto) {
		this.vinPhoto = vinPhoto;
	}

	/**
	 * @return the vinPhoto
	 */
	public String getVinPhoto() {
		return vinPhoto;
	}

	/**
	 * @param photo1 the photo1 to set
	 */
	public void setPhoto1(String photo1) {
		this.photo1 = photo1;
	}

	/**
	 * @return the photo1
	 */
	public String getPhoto1() {
		return photo1;
	}

	/**
	 * @param photo2 the photo2 to set
	 */
	public void setPhoto2(String photo2) {
		this.photo2 = photo2;
	}

	/**
	 * @return the photo2
	 */
	public String getPhoto2() {
		return photo2;
	}

	/**
	 * @param photo3 the photo3 to set
	 */
	public void setPhoto3(String photo3) {
		this.photo3 = photo3;
	}

	/**
	 * @return the photo3
	 */
	public String getPhoto3() {
		return photo3;
	}

	/**
	 * @param photo4 the photo4 to set
	 */
	public void setPhoto4(String photo4) {
		this.photo4 = photo4;
	}

	/**
	 * @return the photo4
	 */
	public String getPhoto4() {
		return photo4;
	}

	/**
	 * @param photo5 the photo5 to set
	 */
	public void setPhoto5(String photo5) {
		this.photo5 = photo5;
	}

	/**
	 * @return the photo5
	 */
	public String getPhoto5() {
		return photo5;
	}

	/**
	 * @param photo6 the photo6 to set
	 */
	public void setPhoto6(String photo6) {
		this.photo6 = photo6;
	}

	/**
	 * @return the photo6
	 */
	public String getPhoto6() {
		return photo6;
	}

	/**
	 * @param photo7 the photo7 to set
	 */
	public void setPhoto7(String photo7) {
		this.photo7 = photo7;
	}

	/**
	 * @return the photo7
	 */
	public String getPhoto7() {
		return photo7;
	}

	/**
	 * @param photo8 the photo8 to set
	 */
	public void setPhoto8(String photo8) {
		this.photo8 = photo8;
	}

	/**
	 * @return the photo8
	 */
	public String getPhoto8() {
		return photo8;
	}

	/**
	 * @param attestStatus the attestStatus to set
	 */
	public void setAttestStatus(int attestStatus) {
		this.attestStatus = attestStatus;
	}

	/**
	 * @return the attestStatus
	 */
	public int getAttestStatus() {
		return attestStatus;
	}

	/**
	 * @param checkStatus the checkStatus to set
	 */
	public void setCheckStatus(int checkStatus) {
		this.checkStatus = checkStatus;
	}

	/**
	 * @return the checkStatus
	 */
	public int getCheckStatus() {
		return checkStatus;
	}

	/**
	 * @param checkImgPath the checkImgPath to set
	 */
	public void setCheckImgPath(String checkImgPath) {
		this.checkImgPath = checkImgPath;
	}

	/**
	 * @return the checkImgPath
	 */
	public String getCheckImgPath() {
		return checkImgPath;
	}

	/**
	 * @param insertTime the insertTime to set
	 */
	public void setInsertTime(Timestamp insertTime) {
		this.insertTime = insertTime;
	}

	/**
	 * @return the insertTime
	 */
	public Timestamp getInsertTime() {
		return insertTime;
	}

	/**
	 * @param insertTimeS the insertTimeS to set
	 */
	public void setInsertTimeS(String insertTimeS) {
		this.insertTimeS = insertTimeS;
	}

	/**
	 * @return the insertTimeS
	 */
	public String getInsertTimeS() {
		return insertTimeS;
	}

	/**
	 * @param insertUser the insertUser to set
	 */
	public void setInsertUser(String insertUser) {
		this.insertUser = insertUser;
	}

	/**
	 * @return the insertUser
	 */
	public String getInsertUser() {
		return insertUser;
	}

	/**
	 * @param isMatch the isMatch to set
	 */
	public void setIsMatch(int isMatch) {
		this.isMatch = isMatch;
	}

	/**
	 * @return the isMatch
	 */
	public int getIsMatch() {
		return isMatch;
	}

	/**
	 * @param cssFlag the cssFlag to set
	 */
	public void setCssFlag(int cssFlag) {
		this.cssFlag = cssFlag;
	}

	/**
	 * @return the cssFlag
	 */
	public int getCssFlag() {
		return cssFlag;
	}

	/**
	 * @param carPhoto the carPhoto to set
	 */
	public void setCarPhoto(String carPhoto) {
		this.carPhoto = carPhoto;
	}

	/**
	 * @return the carPhoto
	 */
	public String getCarPhoto() {
		return carPhoto;
	}

	/**
	 * @param num the num to set
	 */
	public void setNum(int num) {
		this.num = num;
	}

	/**
	 * @return the num
	 */
	public int getNum() {
		return num;
	}

	/**
	 * @param serial the serial to set
	 */
	public void setSerial(String serial) {
		this.serial = serial;
	}

	/**
	 * @return the serial
	 */
	public String getSerial() {
		return serial;
	}

	/**
	 * @param checkPhoto1 the checkPhoto1 to set
	 */
	public void setCheckPhoto1(String checkPhoto1) {
		this.checkPhoto1 = checkPhoto1;
	}

	/**
	 * @return the checkPhoto1
	 */
	public String getCheckPhoto1() {
		return checkPhoto1;
	}

	/**
	 * @param checkPhoto2 the checkPhoto2 to set
	 */
	public void setCheckPhoto2(String checkPhoto2) {
		this.checkPhoto2 = checkPhoto2;
	}

	/**
	 * @return the checkPhoto2
	 */
	public String getCheckPhoto2() {
		return checkPhoto2;
	}

	/**
	 * @param checkPhoto3 the checkPhoto3 to set
	 */
	public void setCheckPhoto3(String checkPhoto3) {
		this.checkPhoto3 = checkPhoto3;
	}

	/**
	 * @return the checkPhoto3
	 */
	public String getCheckPhoto3() {
		return checkPhoto3;
	}

	/**
	 * @param checkPhoto4 the checkPhoto4 to set
	 */
	public void setCheckPhoto4(String checkPhoto4) {
		this.checkPhoto4 = checkPhoto4;
	}

	/**
	 * @return the checkPhoto4
	 */
	public String getCheckPhoto4() {
		return checkPhoto4;
	}

	/**
	 * @param checkPhoto5 the checkPhoto5 to set
	 */
	public void setCheckPhoto5(String checkPhoto5) {
		this.checkPhoto5 = checkPhoto5;
	}

	/**
	 * @return the checkPhoto5
	 */
	public String getCheckPhoto5() {
		return checkPhoto5;
	}

	/**
	 * @param checkPhoto6 the checkPhoto6 to set
	 */
	public void setCheckPhoto6(String checkPhoto6) {
		this.checkPhoto6 = checkPhoto6;
	}

	/**
	 * @return the checkPhoto6
	 */
	public String getCheckPhoto6() {
		return checkPhoto6;
	}

	/**
	 * @param checkPhoto7 the checkPhoto7 to set
	 */
	public void setCheckPhoto7(String checkPhoto7) {
		this.checkPhoto7 = checkPhoto7;
	}

	/**
	 * @return the checkPhoto7
	 */
	public String getCheckPhoto7() {
		return checkPhoto7;
	}

	/**
	 * @param checkPhoto8 the checkPhoto8 to set
	 */
	public void setCheckPhoto8(String checkPhoto8) {
		this.checkPhoto8 = checkPhoto8;
	}

	/**
	 * @return the checkPhoto8
	 */
	public String getCheckPhoto8() {
		return checkPhoto8;
	}

	/**
	 * @param checkPhoto9 the checkPhoto9 to set
	 */
	public void setCheckPhoto9(String checkPhoto9) {
		this.checkPhoto9 = checkPhoto9;
	}

	/**
	 * @return the checkPhoto9
	 */
	public String getCheckPhoto9() {
		return checkPhoto9;
	}

	/**
	 * @param checkPhoto10 the checkPhoto10 to set
	 */
	public void setCheckPhoto10(String checkPhoto10) {
		this.checkPhoto10 = checkPhoto10;
	}

	/**
	 * @return the checkPhoto10
	 */
	public String getCheckPhoto10() {
		return checkPhoto10;
	}

	/**
	 * @param checkPhoto11 the checkPhoto11 to set
	 */
	public void setCheckPhoto11(String checkPhoto11) {
		this.checkPhoto11 = checkPhoto11;
	}

	/**
	 * @return the checkPhoto11
	 */
	public String getCheckPhoto11() {
		return checkPhoto11;
	}

	/**
	 * @param checkPhoto12 the checkPhoto12 to set
	 */
	public void setCheckPhoto12(String checkPhoto12) {
		this.checkPhoto12 = checkPhoto12;
	}

	/**
	 * @return the checkPhoto12
	 */
	public String getCheckPhoto12() {
		return checkPhoto12;
	}

	/**
	 * @param checkPhoto13 the checkPhoto13 to set
	 */
	public void setCheckPhoto13(String checkPhoto13) {
		this.checkPhoto13 = checkPhoto13;
	}

	/**
	 * @return the checkPhoto13
	 */
	public String getCheckPhoto13() {
		return checkPhoto13;
	}

	/**
	 * @param checkPhoto15 the checkPhoto15 to set
	 */
	public void setCheckPhoto15(String checkPhoto15) {
		this.checkPhoto15 = checkPhoto15;
	}

	/**
	 * @return the checkPhoto15
	 */
	public String getCheckPhoto15() {
		return checkPhoto15;
	}

	/**
	 * @param checkPhoto14 the checkPhoto14 to set
	 */
	public void setCheckPhoto14(String checkPhoto14) {
		this.checkPhoto14 = checkPhoto14;
	}

	/**
	 * @return the checkPhoto14
	 */
	public String getCheckPhoto14() {
		return checkPhoto14;
	}

	/**
	 * @param mileage the mileage to set
	 */
	public void setMileage(int mileage) {
		this.mileage = mileage;
	}

	/**
	 * @return the mileage
	 */
	public int getMileage() {
		return mileage;
	}

	/**
	 * @param color the color to set
	 */
	public void setColor(int color) {
		this.color = color;
	}

	/**
	 * @return the color
	 */
	public int getColor() {
		return color;
	}

	/**
	 * @param tag1Skip the tag1Skip to set
	 */
	public void setTag1Skip(int tag1Skip) {
		this.tag1Skip = tag1Skip;
	}

	/**
	 * @return the tag1Skip
	 */
	public int getTag1Skip() {
		return tag1Skip;
	}

	/**
	 * @param tag2Skip the tag2Skip to set
	 */
	public void setTag2Skip(int tag2Skip) {
		this.tag2Skip = tag2Skip;
	}

	/**
	 * @return the tag2Skip
	 */
	public int getTag2Skip() {
		return tag2Skip;
	}

	/**
	 * @param tag3Skip the tag3Skip to set
	 */
	public void setTag3Skip(int tag3Skip) {
		this.tag3Skip = tag3Skip;
	}

	/**
	 * @return the tag3Skip
	 */
	public int getTag3Skip() {
		return tag3Skip;
	}

	public String getTempLicensePlate() {
		return tempLicensePlate;
	}

	public void setTempLicensePlate(String tempLicensePlate) {
		this.tempLicensePlate = tempLicensePlate;
	}

	

}
